﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CcMath
{
    /// <summary>
    /// 统计值，包括最大值，最小值，平均值，标准差
    /// </summary>
    public class StatisticValue
    {
        /// <summary>
        /// 最大值
        /// </summary>
        public float Maximum { get; set; }
        /// <summary>
        /// 最小值
        /// </summary>
        public float Minimum { get; set; }
        /// <summary>
        /// 平均值
        /// </summary>
        public float Mean { get; set; }
        /// <summary>
        /// 标准差
        /// </summary>
        public float StandardDev { get; set; }
        public StatisticValue(double max, double min, double mean, double sdev)
        {
            Maximum = (float)max;
            Minimum = (float)min;
            Mean = (float)mean;
            StandardDev = (float)sdev;
        }
        public StatisticValue(IEnumerable<float> values)
        {
            Maximum = values.Max();
            Minimum = values.Min();
            Mean = values.Average();
            StandardDev = (float)values.StandardDeviation();
        }
        public StatisticValue(IEnumerable<double> values)
        {
            Maximum = (float)values.Max();
            Minimum = (float)values.Min();
            Mean = (float)values.Average();
            StandardDev = (float)values.StandardDeviation();
        }
    }
}
